package io.renren.modules.dataDisplay02.controller;


import io.renren.common.utils.R;
import io.renren.modules.echarts.entity.AttendanceDate;
import io.renren.modules.echarts.entity.TeacherEvaltionPieEntity;
import io.renren.modules.echarts.service.AttendenceChartsService;
import io.renren.modules.echarts.service.TeacherEvaluationChartsService;
import io.renren.modules.echarts.service.TeacherPortraitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Iterator;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/allSchoolEcharts")
public class AllSchoolController {

    @Autowired
    TeacherEvaluationChartsService teacherEvaluationChartsService;
    @Autowired
    TeacherPortraitService teacherPortraitService;
    @Autowired
    AttendenceChartsService attendenceChartsService;

    //有课无课占比
    @RequestMapping("getTeacherCourseEcharts")
    public R getAllDisplayEcharts(@RequestParam Map<String, Object> params) {
        //有课率查询
        List hasCourse =teacherEvaluationChartsService.getTeacherWorkEcharts(params);
        Map<String,Object> hasCourseTime =teacherEvaluationChartsService.getTeacherWorkTimeRate(params);
        return R.ok().put("hasCourse", hasCourse).put("hasCourseTime",hasCourseTime);
    }

    //出勤情况
    @RequestMapping("getTeacherAttendenceEcharts")
    public R getTeacherAttendenceEcharts(@RequestParam Map<String, Object> params) {
        //出勤情况饼状图
        List<AttendanceDate> teacherAttendancePie=teacherPortraitService.getTeacherAttendancePie(params);
        //出勤情况纵向比

        Map<String,Object> teacherAttendanceTimePie =teacherPortraitService.getTecaherAttendanceCollegeHorizontalComparison(params);

        return R.ok().put("teacherAttendancePie", teacherAttendancePie).put("teacherAttendanceTimePie",teacherAttendanceTimePie);
    }
    //出勤情况横向比
    @RequestMapping("getTeacherAttendenceEcharts02")
    public R getTeacherDataEcharts(@RequestParam Map<String, Object> params) {
        //出勤情况饼状图
        List<AttendanceDate> teacherAttendancePie=teacherPortraitService.getTeacherAttendancePie(params);
        //学院出勤情况横向比
        Map<String,Object> collegeTeacherEvaltion =teacherPortraitService.getTeacherAttendanceOfCollege01(params);

        return R.ok().put("collegeTeacherEvaltion", collegeTeacherEvaltion).put("teacherAttendancePie", teacherAttendancePie);
    }

    //教学内容相符率
    @RequestMapping("teacherProgressEcharts")
    public R teacherProgressEcharts(@RequestParam Map<String, Object> params){
        //相符率
        List<TeacherEvaltionPieEntity>  CoincidenceRate=teacherEvaluationChartsService.getiMatchContentRate(params);
        //教学内容相符率纵向比
        Map<String,List> timeLine=teacherPortraitService.getiMatchContentRateTimeLine(params);

//        //分科目相符率
//        List<EchartsDate> rateBar=teacherEvaluationChartsService.getTeacherEvaltionRateBar(params);
        return R.ok().put("coincidenceRate",CoincidenceRate).put("timeLine",timeLine);
    }

    //到课率
    @RequestMapping("studentAttendance")
    public R studentAttendance(@RequestParam Map<String, Object> params){
        //到课率
        Map  CoincidenceRate=attendenceChartsService.studentAttendanceRate(params);

        Map<String,List> timeLine=attendenceChartsService.studentAttendanceRateTimeLine(params);

//        //分科目相符率
//        List<EchartsDate> rateBar=teacherEvaluationChartsService.getTeacherEvaltionRateBar(params);
        return R.ok().put("coincidenceRate",CoincidenceRate).put("timeLine",timeLine);
    }

    //迟到早退排名
    @RequestMapping("getTeacherChidaoZaotuiEcharts")
    public R getTeacherChidaoZaotuiEcharts(@RequestParam Map<String, Object> params){
        //迟到前十名
        Map  chidao=teacherPortraitService.getTeacherChidao(params);
        //早退前十名
        Map<String,List> zaotui=teacherPortraitService.getTeacherZaotui(params);
//      //分科目相符率
//      List<EchartsDate> rateBar=teacherEvaluationChartsService.getTeacherEvaltionRateBar(params);
        return R.ok().put("chidao",chidao).put("zaotui",zaotui);
    }

    //教学进度相符率各学院对比图
    @RequestMapping("teacherProgressOfCollegeEcharts")
    public R teacherProgressOfCollegeEcharts(@RequestParam Map<String, Object> params) {
        //相符率饼状图
        List<TeacherEvaltionPieEntity>  CoincidenceRate=teacherEvaluationChartsService.getiMatchContentRate(params);
        //教学内容相符率各学院对比图
        Map<String,List> college=teacherPortraitService.getiMatchContentRateOfCollege(params);

        return R.ok().put("CoincidenceRate", CoincidenceRate).put("college", college);
    }


    //专业到课率趋势图
    @RequestMapping("/getAttendanceProfessionHorizontalComparison")
    public R getAttendanceProfessionHorizontalComparison(@RequestParam Map<String, Object> params) {
        //到课率
        Map  CoincidenceRate=attendenceChartsService.studentAttendanceRate(params);
        Map<String,List> map =attendenceChartsService.getAttendanceProfessionHorizontalComparison(params);
        return R.ok().put("r",map).put("CoincidenceRate",CoincidenceRate);
    }

    //班级到课率趋势图
    @RequestMapping("/getAttendanceClassHorizontalComparison")
    public R getAttendanceClassHorizontalComparison(@RequestParam Map<String, Object> params) {
        //到课率
        Map  CoincidenceRate=attendenceChartsService.studentAttendanceRate(params);
        Map<String,List> map =attendenceChartsService.getAttendanceClassHorizontalComparison(params);
        return R.ok().put("r",map).put("CoincidenceRate",CoincidenceRate);
    }

}
